layui.use(['table', 'form', 'jquery', 'common'], function() {
			let table = layui.table;
			let form = layui.form;
			let $ = layui.jquery;
			let common = layui.common;

			let cols = [
				[{
						title: 'ID',
						field: 'id',
						align: 'center',
						width: 100
					},
					{
						title: '商户号',
						field: 'pid',
						align: 'center'
					},
					{
						title: '风控类型',
						field: 'type',
						templet: "#type",
						align: 'center',
					},
					{
						title: '风控网址',
						field: 'url',
						align: 'center',
					},
					{
						title: '风控内容',
						field: 'content',
						align: 'center'
					},
					{
						title: '时间',
						field: 'date',
						align: 'center'
					}
				]
			]

			table.render({
				elem: '#user-table',
				url: '/h/ajax/RiskgetDataList',
				page: true,
				cols: cols,
				cellMinWidth: 100,
				skin: 'line',
				toolbar: '#user-toolbar',
				defaultToolbar: [{
					title: '刷新',
					layEvent: 'refresh',
					icon: 'layui-icon-refresh',
				}, 'filter', 'print', 'exports']
			});


			table.on('toolbar(user-table)', function(obj) {
				if (obj.event === 'refresh') {
					window.refresh();
				}else if(obj.event === 'allRemove'){
				    window.allRemove(obj);
				}
			});

			form.on('submit(user-query)', function(data) {
				// console.log(data.field)
				table.reload('user-table', {
					where: data.field,
					page:{curr:1}
				})
				return false;
			});
            window.allRemove = function(obj) {
				layer.confirm('确定要清理这些记录？', {
					icon: 3,
					title: '提示'
				}, function(index) {
					layer.close(index);
					let loading = layer.load();
					$.ajax({
						type: 'POST',
						url: "/h/ajax/del_allrisk",
						dataType: 'json',
						success: function(data) {
							layer.close(loading);
							if (data.code == 200) {
								layer.msg(data.msg, {
									icon: 1,
									time: 1000
								});
								table.reload('user-table');
							} else {
								layer.msg(data.msg,{
								    icon: 2,
									time: 1000
								});
							}
						},
						error: function(data) {
						    layer.close(loading);
							layer.msg('服务器错误',{
								    icon: 2,
									time: 1000
								});
							return false;
						}
					});
				})
			}
			window.refresh = function(param) {
				table.reload('user-table');
			}
		})